<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;

class ElectricElectricity extends Model
{
    public $timestamps = false;
    protected $connection = "mysql_center";
    protected $table = 'electric_electricity';

    public function one_community()
    {
        return $this->hasOne(ElectricCommunity::class, "id", "community")->selectRaw("id,name");
    }

    public function electric_collector()
    {

        return $this->hasOne(ElectricCollector::class, "id", "collect_id")->selectRaw("id,name");
    }
//    public function total_count1()
//    {
//
//        return $this->hasMany(ElectricMeterReadingLog::class, "meter_id", "id");
//    }

    /**
     * @return HasOne
     */
    public function one_collector(): HasOne
    {
        return $this->hasOne(ElectricCollector::class, 'id', 'collect_id')->selectRaw("id,name");
    }

    /**
     * @return HasOne
     */
    public function one_plan(): HasOne
    {
        return $this->hasOne(ElectricChargingScheme::class, 'id', 'charge_id')->selectRaw('id,plan_title');
    }

    /**
     * @return HasOne
     */
    public function one_alarm(): HasOne
    {
        return $this->hasOne(ElectricAlarmPlan::class, 'id', 'alarm_id')->selectRaw('id,plan_title');
    }
    /**
     * @return HasOne
     */
    public function parent_code(): HasOne
    {
        return $this->hasOne(ElectricElectricity::class, 'id', 'electric_id')->selectRaw('id,code');
    }
//    /**
//     * @return BelongsTo
//     */
//    public function owner(): BelongsTo
//    {
//        return $this->belongsTo(Users::class, "electric_id", "id");
//    }
}
